package com.kool.kreport.controller;

import com.kool.kreport.common.bean.ListResult;
import com.kool.kreport.common.bean.ObjectResult;
import com.kool.kreport.common.util.ResultUtil;
import com.kool.kreport.request.GetClientTopDailyReportReq;
import com.kool.kreport.request.GetGlobalDailyReportReq;
import com.kool.kreport.request.GetTopicTopDailyReportReq;
import com.kool.kreport.request.GetUserTopDailyReportReq;
import com.kool.kreport.service.QueryService;
import com.kool.kreport.vo.ClientTopReport;
import com.kool.kreport.vo.DailyReportVo;
import com.kool.kreport.vo.TopicTopReport;
import com.kool.kreport.vo.UserTopReport;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author luyu
 * @date 2021-04-19 23:23
 */
@RestController
public class QueryController {
    @Resource
    private QueryService queryService;

    /**
     * 查询平台日报表
     *
     * @param request
     * @return
     */
    @PostMapping("/getGlobalDailyReport")
    public ListResult<DailyReportVo> getGlobalDailyReport(@RequestBody @Valid GetGlobalDailyReportReq request) {
        return ResultUtil.success(queryService.getGlobalDailyReport(request));
    }

    /**
     * 查询主题top日报表
     *
     * @param request
     * @return
     */
    @PostMapping("/getTopicTopDailyReport")
    public ObjectResult<TopicTopReport> getTopicTopDailyReport(@RequestBody @Valid GetTopicTopDailyReportReq request) {
        return ResultUtil.success(queryService.getTopicTopDailyReport(request.getDay(), request.getTop()));
    }

    /**
     * 查询用户top日报表
     *
     * @param request
     * @return
     */
    @PostMapping("/getUserTopDailyReport")
    public ObjectResult<UserTopReport> getUserTopDailyReport(@RequestBody @Valid GetUserTopDailyReportReq request) {
        return ResultUtil.success(queryService.getUserTopDailyReport(request.getDay(), request.getTop()));
    }

    /**
     * 查询客户端top日报表
     *
     * @param request
     * @return
     */
    @PostMapping("/getClientTopDailyReport")
    public ObjectResult<ClientTopReport> getClientTopDailyReport(@RequestBody @Valid GetClientTopDailyReportReq request) {
        return ResultUtil.success(queryService.getClientTopDailyReport(request.getDay(), request.getTop()));
    }
}
